using System;
using System.Drawing;
using System.Windows.Forms;

namespace DBRestriker.Forms
{
	//Note: Drawing problems when resizing columns of the DataGridView
	class FilterView : DataGridView
	{
		private const byte SCROLL_BORDER = 1;

		public FilterView()
		{
			HorizontalScrollBar.Visible = true;
			HorizontalScrollBar.VisibleChanged += VisibleChangedEventHandler;
		}

		private void VisibleChangedEventHandler(object sender, EventArgs e)
		{
			ScrollBar horizontalScrollBar = HorizontalScrollBar;
			if (sender.Equals(horizontalScrollBar))
			{
				horizontalScrollBar.Location = new Point(0 + SCROLL_BORDER, ClientRectangle.Height - horizontalScrollBar.Height - SCROLL_BORDER);
				horizontalScrollBar.Size = new Size(ClientRectangle.Width - SCROLL_BORDER, horizontalScrollBar.Height);
				if (!horizontalScrollBar.Visible)
				{
					// Horizontal scrollbar always visible
					horizontalScrollBar.Show();
				}
			}
		}
	}
}
